import { ref, computed } from 'vue'
import { defineStore } from 'pinia'
import myCookies from '@/utils/myCookies';

export const useCounterStore = defineStore('counter', () => {
  const keyword = ref()



  //用户信息
  const userInfo = ref()



  return { keyword, userInfo }
})
export const useMessage = defineStore('message', () => {
  //获取用户信息
  const userInfoItem = localStorage.getItem("userInfo")
  const userInfo = ref()
  if (userInfoItem != null) {
    userInfo.value = JSON.parse(userInfoItem)
  }
  const userId = ref()
  const message = ref<{
    role: string;
    id: any;
    createAt: number;
    content: any;
  }[]>([])
  const roleInfo = ref({
    user: {
      name: userInfo.value.nickname,
      avatar: userInfo.value.avatar
    },
    shangjia: {
      name: '商家',
      avatar: '/profile/logo.png'
    },
    system: {
      name: 'System',
      avatar: '/src/assets/logo.png'
    }
  })
  return { userId, message, roleInfo }
})
